import axios from "axios";
import {Toast} from "antd-mobile";

/*
* 请求拦截
* */
axios.interceptors.request.use(function (config) {
  Toast.loading("加载中...", 0);
  return config;
}, function (error) {
  console.log("request error");
  Toast.hide();
  Toast.fail("请求错误", 3);
  return Promise.reject("request error");
});

/*
*
* 响应拦截
* */

axios.interceptors.response.use(function (config) {
  Toast.hide();
  return config;
}, function (error) {
  console.log("response error");
  Toast.hide();
  Toast.fail("返回结果有误", 3);
  return Promise.reject("response error");
});

